//
// Created by Administrator on 2025/3/18.
//

#ifndef LVGL_UI_ELF_GAME_COMMON_H
#define LVGL_UI_ELF_GAME_COMMON_H
#include "../../ui_screen_common/cc_screen_common.h"
#include "../data_dao/elf_game_data_dao.h"

typedef void (*ui_elf_game_screen_deinit)();

// 精灵游戏界面结构体
typedef struct {
    lv_obj_t *screen;
    lv_group_t *group;
    ui_elf_game_screen_deinit deinit_cb; // 退出当前界面回调函数
    lv_obj_t *last_screen;
    lv_group_t *last_group;
    ui_elf_game_screen_deinit last_deinit_cb; // 上一个界面退出回调函数
    int current_page; // 当前页面
    lv_timer_t *full_screen_load_timer;// 全屏加载定时器
    lv_timer_t *flutter_timer; // 飘字定时器
    lv_timer_t *flutter_show_and_hide_timer; // 飘字显示和隐藏定时器
} ui_elf_game_main_screen_t;

// 精灵游戏模块结构体
typedef struct {
    ui_elf_game_main_screen_t *screen;
    elf_game_data_t *data;

}elf_game_module_t;


// 精灵游戏事件数据
typedef struct {
    int index;
    int obj_type;
    lv_obj_t *prev_obj;
    lv_obj_t *next_obj;
    lv_obj_t *extra_obj;

}elf_game_event_data_t;



// 精灵游戏对象类型
enum {
    UI_ELF_GAME_OBJ_TYPE_NONE = 0,
    UI_ELF_GAME_OBJ_TYPE_RETURN_PANEL,
    UI_ELF_GAME_OBJ_TYPE_PROP_BAR_ITEM,
    UI_ELF_GAME_OBJ_TYPE_PROP_ITEM,

};

// 当前页面枚举
enum {
    ELF_GAME_NONE = 0, // 无页面
    ELF_GAME_FULL_LOAD_SCREEN, // 全屏加载页面
    ELF_GAME_ELF_INFO_SCREEN, // 精灵信息页面
    ELF_GAME_ELF_NOT_CONNECT_NET_SCREEN, // 网络未连接页面
    ELF_GAME_DATA_SYNC_SCREEN, // 数据同步页面
    ELF_GAME_BUY_PROP_SCREEN, // 购买道具页面
};

extern ui_elf_game_main_screen_t ui_elf_game_main_screen;
extern elf_game_data_t elf_game_data;
extern elf_game_module_t elf_game_module;

LV_IMG_DECLARE(elf_elf_img)
LV_IMG_DECLARE(elf_elf_img2)
LV_IMG_DECLARE(elf_flutter_word_img)
LV_IMG_DECLARE(elf_load_main_img)
LV_IMG_DECLARE(elf_not_connect_net_icon_img)
LV_IMG_DECLARE(elf_not_connect_net_label_img)
LV_IMG_DECLARE(elf_data_sync_img)

// 宠物信息页面飘字
lv_obj_t *ui_elf_flutter_panel(lv_obj_t *parent,char *word);
// 隐藏当前屏幕
void ui_elf_hide_current_screen();
void ui_elf_refresh_last_screen();
void ui_show_use_prop_prompt(char* name,uint8_t label_type);
void ui_elf_fresh_mood(uint8_t mood,int8_t mood_change);
void ui_elf_fresh_coin(uint32_t coin);
// 恢复飘字显示和隐藏定时器
void ui_elf_game_resume_flutter_show_and_hide_timer();
#endif //LVGL_UI_ELF_GAME_COMMON_H
